package com.itheima.d6_jdk8_time;
import java.time.LocalDate;
import java.time.LocalDateTime;
import java.time.LocalTime;

public class Test1_LocalDate {
    public static void main(String[] args) {
        // 0、获取本地日期对象(不可变对象)
        LocalDate nowDay = LocalDate.now();
        LocalTime nowTime = LocalTime.now();
        LocalDateTime localDateTime = LocalDateTime.now();
        LocalDate.of(2,4,12);
        // 1、获取日期对象中的信息(年，月，日，星期获取)
        int year = nowDay.getYear();
        nowDay.getMonth();
        int dayOfMonth = nowDay.getDayOfMonth();
        // 2、直接修改某个信息: withYear、withMonth、withDayOfMonth、withDayOfYear
        LocalDate localDate = nowDay.withYear(2030);
        // 3、把某个信息加多少: plusYears、plusMonths、plusDays、plusWeeks
        LocalDate localDate1 = nowDay.plusYears(100);
        // 4、把某个信息减多少：minusYears、minusMonths、minusDays、minusWeeks
        LocalDate localDate2 = nowDay.minusYears(20);
        // 5、获取指定日期的LocalDate对象： public static LocalDate of(int year, int month, int dayOfMonth)
        LocalDate of = localDate.of(2023, 2, 26);
        // 6、判断2个日期对象，是否相等，在前还是在后： equals isBefore isAfter
        System.out.println(localDate.equals(localDate1));
        System.out.println(localDate.isBefore(localDate2));
        System.out.println(localDate.isAfter(localDate2));
    }
}
